package com.test;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import com.pd.mvc.utils.StringUtils;

@SpringBootApplication
@MapperScan("com.test.*.mapper")
public class App {
	protected static final Logger log = LoggerFactory.getLogger(App.class);

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(App.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String path = env.getProperty("server.servlet.context-path");
		if (StringUtils.isBlank(path)) {
			path = "";
		}
		log.info("\n----------------------------------------------------------\n\t"
				+ "Application System is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:"
				+ port
				+ path
				+ "/\n\t"
				+ "External: \thttp://"
				+ ip
				+ ":"
				+ port
				+ path
				+ "/\n\t"
				+ "swagger-ui: \thttp://"
				+ ip
				+ ":"
				+ port
				+ path
				+ "/swagger-ui.html\n\t"
				+ "Doc: \t\thttp://"
				+ ip
				+ ":" + port + path + "/doc.html\n" + "----------------------------------------------------------");

	}

}
